//------------------------------------------------------------------------------
//SFWK Framework
//Copyright (C) 2011 SQLI

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------

using System;
using System.Reflection;

namespace SFWK.Core.Unity.DynamicProxy
{
	/// <summary>
	/// Delegate for implementing the invocation task in a Dynamic Proxy
	/// <code>
	/// Example of an invocation handler
	/// DynamicProxyFactory.Instance.CreateProxy(testClass, new InvocationDelegate(InvocationHandler))
	/// 
	/// private static object InvocationHandler(object target, MethodBase method, object[] parameters) {
	///		Console.WriteLine("Before: " + method.Name);
	///		object result = method.Invoke(target, parameters);
	///		Console.WriteLine("After: " + method.Name);
	///		return result;
	///	}
	/// </code>
	/// </summary>
	public delegate object InvocationDelegate(object target, MethodBase method, object[] parameters);

	/// <summary>
	/// Interface for a dynamic proxy. Through this interface you can work on the proxy instance.
	/// </summary>
	public interface IDynamicProxy {
		/// <summary>
		/// The target object for the proxy (aka. the proxied object)
		/// </summary>
		object ProxyTarget {
			get;
			set;
		}

		/// <summary>
		/// The delegate which handles the invocation task in the dynamic proxy
		/// </summary>
		InvocationDelegate InvocationHandler {
			get;
			set;
		}

		/// <summary>
		/// Type support strictness. Used for cast strictness
		/// </summary>
		bool Strict {
			get; 
			set;
		}

		/// <summary>
		/// List of supported types for cast strictness support. Is only checked if Strict is true
		/// </summary>
		Type[] SupportedTypes {
			get;
			set;
		}
	}
}

